#@layout()
#define main()
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title  am-cf">菜单管理</div>
                </div>
                <div class="widget-body  am-fr">
                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                        <div class="am-form-group">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    #ifHasAuth("/admin/menu/save")
                                    <a class="am-btn am-btn-default am-btn-success" href="/admin/menu/add"><span class="am-icon-plus"></span> 新增</a>
                                    #end
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                        <div class="am-form-group tpl-table-list-select">
                            <select data-am-selected="{btnSize: 'sm'}">
                                <option value=0>全部</option>
                                <option value=1>类别</option>
                                <option value=2>目录</option>
                                <option value=3>页面</option>
                                <option value=4>功能</option>
                            </select>
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                        <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                            <input type="text" class="am-form-field ">
                            <span class="am-input-group-btn">
                                <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" type="button"></button>
                            </span>
                        </div>
                    </div>

                    <div class="am-u-sm-12">
                        <link rel="stylesheet" href="/admin/common/Treegrid/css/jquery.treegrid.css">
                        <script src="/admin/common/Treegrid/js/jquery.treegrid.min.js"></script>
                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="menu-tree">
                            <thead>
                            <tr>
                                <th>菜单名</th>
                                <th>类型</th>
                                <th>权限</th>
                                <th>排序</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            #for(x : menuPage)
                            <tr class="gradeX treegrid-#(x.id) treegrid-parent-#(x.pid==0?'':x.pid)">
                                <td>
                                    #if(x.icon)
                                    <i class="#(x.icon)"></i>
                                    #end
                                    #(x.name)
                                </td>
                                <td>
                                    #if(x.type == 1)
                                    类别
                                    #elseif(x.type == 2)
                                    目录
                                    #elseif(x.type == 3)
                                    页面
                                    #else
                                    功能
                                    #end
                                </td>
                                <td>#(x.permission)</td>
                                <td>#(x.sort)</td>
                                <td>
                                    <div class="tpl-table-black-operation">
                                        #ifHasAuth("/admin/menu/update")
                                            <a href="/admin/menu/edit/#(x.id)">
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                        #end
                                        #ifHasAuth("/admin/menu/save")
                                            #if(x.type <4)
                                            <a href="/admin/menu/add?pid=#(x.id)&pname=#(x.name)&ptype=#(x.type)">
                                                <i class="am-icon-plus"></i>
                                                #if(x.type == 1||x.type==2)
                                                添加子菜单
                                                #else
                                                添加功能
                                                #end
                                            </a>
                                            #end
                                        #end
                                        #ifHasAuth("/admin/menu/delete")
                                            <a href="/admin/menu/delete/#(x.id)" class="tpl-table-black-operation-del">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        #end
                                    </div>
                                </td>
                            </tr>
                            #end
                            </tbody>
                        </table>

                        <script>
                            $(function () {
                                $('#menu-tree').treegrid({
                                    expanderExpandedClass: 'am-icon-minus',
                                    expanderCollapsedClass: 'am-icon-plus'
                                });
                            });
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
#end